<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY copy "&#169;">
  <!ENTITY nbsp "&#160;">
  <!ENTITY laquo "&#171;">
  <!ENTITY raquo "&#187;">
]>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:output encoding="UTF-8"
              method="xml"
              omit-xml-declaration="yes"
              indent="no"
              doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
              doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

  <xsl:variable name="Root" select="/page/settings/url" />
  <xsl:variable name="Files" select="/page/settings/files_url" />
  <xsl:variable name="Images" select="/page/settings/images_url" />
  <xsl:variable name="Settings" select="/page/settings" />
  <xsl:variable name="Controller" select="/page/settings/controller" />
  <xsl:variable name="Action" select="/page/settings/action" />
  <xsl:variable name="This" select="/page/settings/this" />
  <xsl:variable name="Main" select="/page/content/Main" />
  <xsl:variable name="User" select="/page/content/auth-info" />
  <xsl:variable name="Content" select="/page/content" />
  <xsl:variable name="Cats" select="/page/content/Cats" />
  <xsl:variable name="Cat" select="/page/content/@cat" />
  <xsl:variable name="Form" select="/page/content/Main/form" />
  <xsl:variable name="Date" select="/page/content/current-date" />

  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="page">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>
          <xsl:value-of select="$Settings/title"/>
        </title>
        <link href="/css/main.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="/js/jq.js"></script>
        <script type="text/javascript" src="/js/general.js"></script>

        <link rel="stylesheet" type="text/css" href="/js/upload/jquery.fileupload-ui.css" />
        <link href="/js/jquery-ui/css/smoothness/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
        <script src="/js/jquery-ui/jquery-ui.custom.min.js"></script>

        <script type="text/javascript" src="/js/highslide/highslide.js"></script>
        <link rel="stylesheet" type="text/css" href="/js/highslide/highslide.css" />
        <script type="text/javascript" src="/js/highslide/config.js"></script>

        <script src="/js/jcrop/jquery.Jcrop.min.js"></script>
        <link rel="stylesheet" href="/js/jcrop/jquery.Jcrop.css" type="text/css" />
        <script src="/js/jcrop/config.js"></script>
      </head>
      <body>
        <div class="layout">
          <div class="header">

            <div class="user-info">
              <a href="{$Settings/main_url}">
                <xsl:value-of select="$Settings/website_name" />
              </a>  | <a href="javascript:;" class="gotosite" onclick="clean_cache();">почистить Cache</a>  |  <b>
                <a href="/accounts/{$User/id}">
                  <xsl:value-of select="$User/name"/>
                </a>
              </b> |  <a href="/auth/logout">Выход</a>

            </div>
            <div class="mainmenu">
              <ul>
                <xsl:for-each select="$Cats/row[level=3]">
                  <xsl:if test="is_show = 1">
                    <li onmouseover="$(this).find('div.submenu').show(); $(this).addClass('hover');" onmouseout="$(this).find('div.submenu').hide(); $(this).removeClass('hover');">
                      <xsl:if test="id != 89">
                        <xsl:attribute name="class">dropdown</xsl:attribute>
                      </xsl:if>
                      <xsl:choose>
                        <xsl:when test="url != ''">
                          <a href="{url}">
                            <xsl:if test="@active">
                              <xsl:attribute name="class">on</xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="title"/>
                          </a>
                        </xsl:when>
                        <xsl:otherwise>
                          <span>
                            <xsl:if test="@active">
                              <xsl:attribute name="class">on</xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="title"/>
                          </span>
                        </xsl:otherwise>
                      </xsl:choose>

                      <xsl:if test="$Cats/row[parent_id = current()/id and is_show = 1]">
                        <div class="submenu" style="display:none;">
                          <ul>
                            <xsl:for-each select="$Cats/row[parent_id = current()/id and is_show = 1]">
                              <li>
                                <a href="{url}">
                                  <xsl:if test="@active">
                                    <xsl:attribute name="class">on</xsl:attribute>
                                  </xsl:if>
                                  <xsl:value-of select="title"/>
                                </a>
                              </li>
                            </xsl:for-each>
                          </ul>

                        </div>
                      </xsl:if>

                    </li>
                  </xsl:if>
                </xsl:for-each>
              </ul>
              <br class="spacer"/>
            </div>
          </div>





          <div class="content">



            <xsl:apply-templates select="content" />

            <br class="spacer"/>


          </div>


        </div>

        <div class="footer">

          © 2011 <xsl:value-of select="$Settings/title"/>

        </div>

        <div class="highslide-html-content" id="highslide-html">
          <div class="highslide-header">
            <ul>
              <li class="highslide-move">

              </li>

            </ul>
          </div>
          <div class="highslide-body" style="height: 220px">
            <span id="spanButtonPlaceholder"></span>
            <div id="divFileProgressContainer"></div>
            <div id="thumbnails">
              <img/>
              <xsl:for-each select="$Main/photos/row">
                <img style="margin: 5px; opacity: 1; cursor: hand;" src="{$Files}{path}{id}square_small{file_name}" onclick="insert_tiny_img('{$Files}{path}{id}blog{file_name}')"/>
              </xsl:for-each>
            </div>
          </div>
          <div class="go">


            <input type="button"  class="submit" value="Отмена" onclick="return hs.close(this)"/>
          </div>

        </div>


        <!-- Load new avatar -->
        <div class="highslide-html-content " id="avatar_edit">
          <div class="highslide-header">
            <ul>
              <li class="highslide-move">
              </li>
            </ul>
          </div>
          <div class="highslide-body popup-message">
            <form id="form1" action="" enctype="multipart/form-data" method="post">

              <div class="small-text">
                <input type="hidden" id="upload_avatar_url" value="/{$Controller}/upload-avatar/id/{$Main/@id}"/>
                <input type="text" id="txtFileName" disabled="true"   />
                <span id="spanButtonPlaceholderAvatar"></span>
                (10 MB max)
              </div>
              <div class="flash" id="fsUploadProgressAvatar">
                <!-- This is where the file progress gets shown.  SWFUpload doesn't update the UI directly.
											The Handlers (in handlers.js) process the upload events and make the UI updates -->
              </div>


              <div class="small-text">
                <p>Можно загрузить файл формата JPG, GIF или PNG. (Не загружайте картинки, содержащие изображения знаменитостей, обнаженной натуры, произведений искусства, а также изображения, защищенные авторскими правами.)</p>
              </div>

              <div class="go">

                <input type="button"  class="submit" value="Загрузить" onclick="" id="btnSubmit"/>
                <input type="button"  class="submit" value="Отмена" onclick="return hs.close(this)"/>
              </div>
            </form>
          </div>
        </div>

        <!-- General Message Box -->
        <div class="highslide-html-content" id="popup_msg">
          <div class="highslide-header">
            <ul>
              <li class="highslide-move">
              </li>
            </ul>
          </div>
          <div class="highslide-body">
          </div>
        </div>

        <!-- Crop Loaded avatar -->
        <div class="highslide-html-content " id="avatar_crop">
          <div class="highslide-header">
            <ul>
              <li class="highslide-move">
              </li>
            </ul>
          </div>
          <div class="highslide-body popup-message">
            <input value="0" type="hidden" rel="x"/>
            <input value="0" type="hidden" rel="y"/>
            <input value="0" type="hidden" rel="w"/>
            <input value="0" type="hidden" rel="h"/>

            <table>
              <tr>
                <td>
                  <img src="{$Files}{$Form/path}{$Form/id}original{$Form/file_name}" class="cropbox" />
                </td>
                <td>
                  <div style="width:162px;height:125px;overflow:hidden;" class="preview">
                    <img src="{$Files}{$Form/path}{$Form/id}original{$Form/file_name}" class="preview"/>
                  </div>
                </td>
              </tr>
            </table>
            <div class="go">
              <input type="button" class="submit" value="Вырезать" onclick="cropSelected({$Main/@id}, '{$Controller}')"/>
              <input type="button" class="submit" value="Отмена" onclick="window.location.reload( true );"/>
            </div>

          </div>
        </div>


        <div class="upload-window"></div>

      </body>
    </html>
  </xsl:template>


  <xsl:template name="Create_Path">
    <xsl:param name="last"></xsl:param>
    <xsl:param name="last_url"></xsl:param>
    <xsl:param name="without_last"></xsl:param>

    <div class="path">
      <xsl:for-each select="$Content/Path/row">
        <xsl:if test="not($without_last = 1 and position() = last())">
          <xsl:choose>
            <xsl:when test="url != ''">
              <a href="{url}">
                <xsl:value-of select="name"/>
              </a> &gt;
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="name"/> &gt;
            </xsl:otherwise>
          </xsl:choose>
        </xsl:if>

      </xsl:for-each>

      <xsl:choose>
        <xsl:when test="$last_url = ''">
          <xsl:value-of select="$last"/>
        </xsl:when>
        <xsl:otherwise>
          <a href="{$last_url}">
            <xsl:value-of select="$last"/>
          </a>
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>

  <xsl:template name="Messages">
    <xsl:if test="Main/form/@sent = 1">
      <div>
        <xsl:if test="Main/form/@error = 1">
          <xsl:attribute name="class">massage_no</xsl:attribute>
        </xsl:if>
        <xsl:if test="Main/form/@error = 0">
          <xsl:attribute name="class">massage_yes</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="Main/form/@message" />
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template name="Box-File">

    <xsl:if test="$Form/file_name_var != ''">


      <div class="head-slide on">
        Файл
      </div>
      <div class="container">
        <ul class="editlist">
          <li>
            <label>Путь к файлу</label>
            <a href="{$Files}{$Form/path}{$Form/file_name_var}">Скачать</a>
          </li>
          <li>
            <label>Размер</label>
            <xsl:value-of select="$Form/file_size"/>
          </li>
        </ul>
      </div>

    </xsl:if>
  </xsl:template>

  <xsl:template name="Box-CEO">
    <div class="head-slide off">
      META Тэги
    </div>

    <div id="ceo_tags" class="container" style="display:none;">
      <fieldset>
        <ul class="editlist">
          <li>
            <label>Title</label>

            <textarea name="ceo_title" class="broad100">
              <xsl:value-of select="Main/form/ceo_title"/>
            </textarea>

          </li>

          <li>
            <label>META Description</label>

            <textarea name="ceo_desc" class="broad100">
              <xsl:value-of select="Main/form/ceo_desc"/>
            </textarea>

          </li>

          <li>
            <label>META Keywords (через запятую)</label>

            <textarea name="ceo_keywords" class="broad100">
              <xsl:value-of select="Main/form/ceo_keywords"/>
            </textarea>
          </li>
        </ul>
      </fieldset>
    </div>
  </xsl:template>

  <xsl:template name="Box-Avatar">
    <div class="head-slide on">
      Аватар
    </div>

    <div class="container">
      <div>
        <xsl:if test="$Form/file_name != ''">
          <xsl:attribute name="style">display:none</xsl:attribute>
        </xsl:if>
        <a href="javascript:;" onclick="editAvatar()" id="load_avatar" class="upload">Загрузить изображение  </a>
      </div>
      <div class="avacontainer" onmouseover="$(this).find('div.tools').show()" onmouseout="$(this).find('div.tools').hide()">


        <div class="tools" style="display:none">
          <a href="javascript:;" class="editava" onclick="editAvatar()" title="Редактирывать"></a>
          <a href="javascript:;" class="cropava" onclick="cropAvatar($('#avatar').width(),$('#avatar').height())" title="Вырезать"></a>
          <a href="javascript:;" class="removeava" onclick="removeAvatar({$Main/@id}, '{$Controller}')" title="Удалить"></a>
          <a href="{$Files}{$Form/path}{$Form/id}original{$Form/file_name}" title="Оригинал" target="_blank"  class="fullsize"></a>
        </div>       
        

        <img src="{$Files}{$Form/path}{$Form/id}avatar{$Form/file_name}" width="200px" id="avatar" alt="{$Form/title}" title="{$Form/title}">
          <xsl:if test="$Form/file_name = ''">
            <xsl:attribute name="style">display:none</xsl:attribute>
          </xsl:if>
        </img>

      </div>
    </div>
  </xsl:template>

  <xsl:template name="Lang">
    <div class="lang">
      <span>Язык:</span>
      <span id="tab_1" onclick='javascript: change_tab(1);' class='tab on'>Руский</span>
      <span id="tab_2" onclick='javascript: change_tab(2);' class='tab'>Украинский</span>
      <span id="tab_3" onclick='javascript: change_tab(3);' class='tab'>Английский</span>
    </div>
  </xsl:template>

  <xsl:template name="Article-edit-switcher">
    <xsl:param name="active"/>
    <xsl:param name="arts"/>
    <xsl:param name="files"/>
    <div class="innerNav">
      <ul>
        <li>
          <a href="/{$Controller}/{$Main/@id}">
            <xsl:if test="$active = 1">
              <xsl:attribute name="class">on</xsl:attribute>
            </xsl:if>
            Основная информация
          </a>
        </li>
        <li>
          <a href="/{$Controller}/photos/{$Main/@id}">
            <xsl:if test="$active = 2">
              <xsl:attribute name="class">on</xsl:attribute>
            </xsl:if>
            Фотографии
          </a>
        </li>
        <xsl:if test="$arts = 1">
          <li>
            <a href="/{$Controller}/arts/{$Main/@id}">
              <xsl:if test="$active = 3">
                <xsl:attribute name="class">on</xsl:attribute>
              </xsl:if>
              Параметры
            </a>
          </li>
          <li>
            <a href="/{$Controller}/childs/{$Main/@id}">
              <xsl:if test="$active = 4">
                <xsl:attribute name="class">on</xsl:attribute>
              </xsl:if>
              Прикрепленные продукты
            </a>
          </li>
        </xsl:if>
        <xsl:if test="$files = 1">
          <li>
            <a href="/{$Controller}/files/{$Main/@id}">
              <xsl:if test="$active = 5">
                <xsl:attribute name="class">on</xsl:attribute>
              </xsl:if>
              Файлы
            </a>
          </li>
        </xsl:if>
      </ul>
      <br class="spacer"/>
    </div>

  </xsl:template>

  <!-- Write.Date -->
  <xsl:template name="Write.Date">
    <xsl:param name="node"></xsl:param>

    <xsl:choose>
      <xsl:when test="$node/@day = $Date/@day and $node/@dmonth = $Date/@dmonth and $node/@year = $Date/@year">
        Сьогодні
      </xsl:when>
      <xsl:when test="$node/@day = $Date/@day+1 and $node/@dmonth = $Date/@dmonth and $node/@year = $Date/@year">
        Вчора
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$node/@day"/>
        <xsl:text>.</xsl:text>
        <xsl:value-of select="$node/@dmonth"/>
        <xsl:text>.</xsl:text>
        <xsl:value-of select="$node/@year"/>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>

  <!-- Write.Date.Time -->
  <xsl:template name="Write.Date.Time">
    <xsl:param name="node"></xsl:param>
    <xsl:call-template name="Write.Date">
      <xsl:with-param name="node" select="$node"/>
    </xsl:call-template>
    <xsl:text> </xsl:text>
    <xsl:value-of select="$node/@hour"/>
    <xsl:text>:</xsl:text>
    <xsl:value-of select="$node/@minute"/>
  </xsl:template>

</xsl:stylesheet>